package com.smartstate.ems.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smartstate.ems.dto.EnergyDTO;
import com.smartstate.ems.entity.EnergyReport;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface EnergyReportMapper extends BaseMapper<EnergyReport> {

    /**
     * 查询能耗日报
     * @return
     */
    List<EnergyReport> queryEneryDay(long size, long offset,@Param("list") List<String> list);


    /**
     * 获取objId的名称
     * @param deviceId
     * @return
     */
    String queryObjIdName(String deviceId);

    /**
     * 获取指点期限的电能汇总
     * @param time
     * @param deviceId
     * @return
     */
    String queryMeterSum(@Param("energyDTO") EnergyDTO energyDTO, String deviceId);

    /**
     * 查询能耗日报导出
     * @return
     */
    List<EnergyReport> queryExcelEneryDay(List<String> list);

    /**
     * 获取电表类型的deviceId总数
     * @return
     */
    long queryDeviceIdTotal(List<String> list);


    /**
     * 获取空间结构建模下的所有objId
     * @return
     */
    @MapKey("id")
    Map<String, Object> queryAllObjId(String type);

    /**
     * 根据objId查找objIdName
     * @param analysisObject
     * @return
     */
    String queryObjIdNameByObjId(String analysisObject);

    @Select("select id from objmoudel where type = (select id from objtype where name = #{objIdName}) " +
            "and parentId = '0'")
    String queryRootObjId(String objIdName);
}
